package cn.dengta.webapp.im.entity;

import java.util.Date;

import cn.dengta.webapp.base.entity.TimeBasedEntity;
import cn.dengta.webapp.im.enums.GroupUserState;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 群成员信息
 *
 * @author zw
 * @since 2022-06-09
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("im_group_user_map")
public class GroupUserMap extends TimeBasedEntity {

	/** 组id */
	private Long groupId;
	/** 用户id */
	private Long userId;
	/** 用户的群角色: 0=普通用户；1=管理员；2=群主；) */
	private Integer role;
	/** 用户状态: 0=正常；1=退出；2=被踢 */
	private Integer status;
	/** 禁言状态：0=否；1=是 */
	private Integer muteType;
	/** 消息提醒： 0=否；1=是 */
	private Integer remind;
	/** 置顶： 0=否；1=是 */
	private Integer top;
	/** 置顶时间 */
	private Date topTime;
	/** 群昵称 */
	private String nickname;
	/** 系统用户： 0=否；1=是 */
	private Integer systemUser;

	public static final String GROUP_ID = "group_id";
	public static final String USER_ID = "user_id";
	public static final String ROLE = "role";
	public static final String STATUS = "status";
	public static final String MUTE_TYPE = "mute_type";
	public static final String TOP = "top";
	public static final String TOP_TIME = "top_time";
	public static final String NICKNAME = "nickname";
	public static final String SYSTEMUSER = "system_user";

	public static GroupUserMap of(Long groupId, Long userId, int groupCode) {
		Date date = new Date();
		GroupUserMap t = new GroupUserMap();
		t.setGroupId(groupId);
		t.setStatus(GroupUserState.NORMAL.value);
		t.setAddTime(date);
		t.setUpdateTime(date);
		t.setUserId(userId);
		t.setRole(groupCode);
		t.setTop(0);
		t.setRemind(1);
		return t;
	}

}
